﻿@model S4Store.Models.AfterSaleReport.AfterSaleDecoratingReportModel
@{
    ViewBag.Title = "CarBrandDecoratingSaleKPI";
    Layout = null;
}

@{
    var config = Model.MonthConfig.FirstOrDefault();
    var daydata = Model.DayData;
    var curday = daydata.Where(o => o.AddTime.Year == DateTime.Now.Year && o.AddTime.Month == DateTime.Now.Month && o.AddTime.Day == DateTime.Now.Day).FirstOrDefault();
    if (curday == null)
    {
        curday = new S4Store.Domain.AfterSaleKpi.AfterSaleCarDecoratingDayInput();
    }
    
    
 }
 @if(config==null || curday==null){
     
     <p>数据未配置（月初或当日）</p>
         
 }else
 {
<div style="height: 100%; overflow: auto">
@Html.Action("ReportBar", "Common", Model.BarModel)
<div class="pagetitle">
    @(config.CarBrand.Name)用品销售状况KPI
</div>
<table width="100%" border="0" cellpadding="10" cellspacing="1" class="reporttable">
  <tr>
    <th rowspan="2" align="center"><p>项目数据</p></th>
    <th rowspan="2" align="center" class="tb_header_greenbg"><p>用品率目标</p></th>
    <th rowspan="2" align="center"  class="tb_header_greenbg"><p>目标单车用品销售额&#13;</p></th>
    <th colspan="13" align="center"  class="tb_header_greenbg"><p>用品销售&#13;</p></th>
  </tr>
  <tr>
    <th class="tb_header_lightbluebg"><div>本月已交车数</div></th>
    <th class="tb_header_lightbluebg"><div>当日交车台次</div></th>
    <th class="tb_header_lightbluebg"><div>本月<br />
    交车累计</div></th>
    <th class="tb_header_lightbluebg"><div>已实现用品销售台次</div></th>
    <th class="tb_header_lightbluebg"><div>当日用品销售台次</div></th>
    <th class="tb_header_lightbluebg"><div>累计用品销售台次</div></th>
    <th class="tb_header_lightbluebg"><div>已实现用品销售金额</div></th>
    <th class="tb_header_lightbluebg"><div>当日用品销售总额</div></th>
    <th class="tb_header_lightbluebg"><div>累计用品销售总额</div></th>
    <th class="tb_header_lightbluebg"><div>用品用品销售率</div></th>
    <th class="tb_header_lightbluebg"><div>用品用品销售率差异</div></th>
    <th class="tb_header_lightbluebg"><div>平均单车用品销售额</div></th>
    <th class="tb_header_lightbluebg"><div>单车用品金额差异</div></th>
  </tr>
  @{
      var 用品销售总台次 = daydata.Sum(o => o.ZHXSTC_DecoratingSaleCarNum);
      var 交出总台次 = daydata.Sum(o=>o.JCTC_SaleCarNum);
      var 用品用品销售率 = 交出总台次==0?0:(decimal)用品销售总台次/(decimal)交出总台次;
      var 用品销售总额 = daydata.Sum(o => o.ZHXSZE_DecoratingSalesTotalVolume);
      var 平均单车用品销售额 = 用品销售总台次 == 0 ? 0 : 用品销售总额 / (decimal)用品销售总台次;
      var 单车用品金额差异 = 平均单车用品销售额 - config.MBDCZHE_DecoratingTargetValumeOnUnitCar;
      }
  <tr>
    <td>@config.CarBrand.Name </td>
    <td>@config.ZHLMB_DecoratingTargetRate %</td>
    <td>@config.MBDCZHE_DecoratingTargetValumeOnUnitCar</td>

    <td>@(daydata.Sum(o=>o.JCTC_SaleCarNum)-curday.JCTC_SaleCarNum)</td>
    <td>@curday.JCTC_SaleCarNum</td>
    <td>@daydata.Sum(o=>o.JCTC_SaleCarNum)</td>
    
    <td>@(daydata.Sum(o => o.ZHXSTC_DecoratingSaleCarNum) - curday.ZHXSTC_DecoratingSaleCarNum)</td>
    <td>@curday.ZHXSTC_DecoratingSaleCarNum</td>
    <td>@daydata.Sum(o => o.ZHXSTC_DecoratingSaleCarNum)</td>

    <td>@(daydata.Sum(o => o.ZHXSZE_DecoratingSalesTotalVolume) - curday.ZHXSZE_DecoratingSalesTotalVolume)</td>
    <td>@curday.ZHXSZE_DecoratingSalesTotalVolume</td>
    <td>@daydata.Sum(o => o.ZHXSZE_DecoratingSalesTotalVolume)</td>
    
    <td>@((用品用品销售率*100).toInt())%</td>
    <td @if ((用品用品销售率 * 100 - config.ZHLMB_DecoratingTargetRate)<0)
        {
    <text>style="background:#ff1100"</text>
    }>@((用品用品销售率*100 - config.ZHLMB_DecoratingTargetRate).toInt())%</td>
    <td>@Math.Round(平均单车用品销售额,2,MidpointRounding.AwayFromZero)</td>
    <td@if (单车用品金额差异 < 0)
        {
    <text>style="background:#ff1100"</text>
    }>@Math.Round(单车用品金额差异,2,MidpointRounding.AwayFromZero)</td>
  </tr>
</table>
</div>
}